/**
 * Created by Administrator on 2017/4/15 0015.
 */
$('.store').click(function () {
    var url = $(this).attr('data-url');
    window.location.href = url;
})

$('.ajax').click(function () {
    if(confirm('确定要删除吗？')) {
        var url = $(this).attr('data-url');
        $.get(url, function (ret) {
            showMsg(ret.msg, ret.code);
            if (ret.url) setTimeout(function () {
                window.location.href = ret.url;
            }, 1000);
        });
    }
})

$('#distributor').click(function () {
    if (confirm('确定把普通会员变为经销商吗？')) {
        var url = $(this).attr('data-url');
        $.get(url, function (ret) {
            showMsg(ret.msg, ret.code);
            if (ret.url) setTimeout(function () {
                window.location.href = ret.url;
            }, 1000);
        });
    }
})

new checkForm({
    form : '#form',
    btn : '#submit',
    error : function (e,msg){
        showMsg(msg,0,'#form');
    },
    complete : function (form){
        // showProgress('请稍后...');
        var url = form.getAttribute('action');
        var datas = $(form).serializeArray();
        if(typeof(editor) == 'object' && editor.html()) datas[datas.length - 1] = {name:'content',value:editor.html()};
        $.post(url,datas,function(ret){
            showMsg(ret.msg,ret.code);
            if(ret.url) setTimeout(function (){window.location.href = ret.url;},1000);
        },'json');
    }
});